home *** CD-ROM | disk | FTP | other *** search
- Path: cs.tu-berlin.de!news
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Operator overloading
- Date: Fri, 08 Mar 1996 01:48:03 +0100
- Organization: Technical University of Berlin
- Message-ID: <313F83C3.4E90@cs.tu-berlin.de>
- References: <313F19B5.41C6@lfa.uni-wuppertal.de>
- NNTP-Posting-Host: 130.149.17.231
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Oliver Heinz wrote:
- >
- > Hello out there,
- >
- > can somebody explain to me this strange looking operator overloading:
- >
- > const T& operator[](unsigned long int index) const;
- >
- > I know, it is an subscription overloading, for something like
- > v[i], where i is of type unsigned long int and v of type T.
- >
- > What's the meaning of the const at the end
-
- The const at the end means that this member function does not modify the
- its object. E. g. if you have something like this:
-
- const MyArray array(...);
-
- then a call like array[...] is allowed only if operator[] is declared const.
-
- > and the beginning of the line ?
-
- This one means that the object returned by the operator is const.
-
- Bye
-
- Roman
-